summon armor_stand ~ ~ ~ {Tags:[tempSSA],Invisible:true,Small:true,Marker:true,Invulnerable:true}

item replace entity @n[type=armor_stand,distance=..1,tag=tempSSA] weapon.mainhand from entity @s hotbar.8
$data modify entity @n[tag=tempSSA,distance=..1,type=armor_stand] HandItems[0].components."minecraft:custom_data".select_arrow set value $(value)
item replace entity @s hotbar.8 from entity @n[tag=tempSSA,distance=..1,type=armor_stand] weapon.mainhand

kill @n[tag=tempSSA,distance=..1,type=armor_stand]